/*
 * File: Lib_Balance.c
 *
 * Code generated for Simulink model 'FLTM'.
 *
 * Model version                  : 3.153
 * Simulink Coder version         : 9.4 (R2020b) 29-Jul-2020
 * C/C++ source code generated on : Mon Aug  2 13:13:30 2021
 */

#include "Includes.h"


uint8_T BSW_ReadRtcTime(uint8_T *time)
{

	time[0] = RealTime.second;
	time[1] = RealTime.minute;
	time[2] = RealTime.hour;
	time[3] = RealTime.day;
	time[4] = 0;
	time[5] = RealTime.month;
	time[6] = RealTime.year;

    return	TRUE;
}


//uint8_T BSW_SetRTCTime(RTC_TIME_STRUCT time)
//{
//	WriteRTC_Enable();
//
//	if(!I2CStart())
//		return FALSE;
//
//	I2CSendByte(RTC_Address);
//
//	if(!I2CWaitAck())
//	{
//		I2CStop();
//	    return FALSE;
//	}
//	I2CSendByte(0x00);
//	I2CWaitAck();
//	I2CSendByte(time.second);
//	I2CWaitAck();
//	I2CSendByte(time.minute);
//	I2CWaitAck();
//	I2CSendByte(time.hour|0x80);
//	I2CWaitAck();
//	I2CSendByte(time.week);
//	I2CWaitAck();
//	I2CSendByte(time.day);
//	I2CWaitAck();
//	I2CSendByte(time.month);
//	I2CWaitAck();
//	I2CSendByte(time.year);
//	I2CWaitAck();
//	I2CStop();
//
//	I2CWriteOneByte(RTC_Address,TTF,0);
//
//	WriteRTC_Disable();
//	return	TRUE;
//}



//
//		if(flg == 0)
//		{
//
//			times.year = HEX2BCD(22);
//			times.month = HEX2BCD(1);
//			times.day = HEX2BCD(18);
//			times.week = HEX2BCD(2);
//			times.hour = HEX2BCD(18);
//			times.minute = HEX2BCD(5);
//			times.second =HEX2BCD(0);
//
//			BSW_SetRTCTime(times);
//			flg = 1;
//		}

//RTC_TIME_STRUCT times;
//static uint8_t HEX2BCD(uint8_t Data_HEX)
//{
//	uint8_t temp,temp1 =0,temp2=0;
//	temp1 =  Data_HEX/10;
//	temp2 =  Data_HEX%10;
//	temp1 <<= 4;
//	temp = temp1|temp2;
//	return temp;
//}

